package adminlte.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
 * @author ZHUFEIFEI
 */
@Slf4j
@ControllerAdvice
public class ErrorController {

    @ExceptionHandler({Throwable.class})
    @ResponseStatus(reason = "please contact administrator!")
    public String exception(Throwable e, Model model) {
        log.error(e.getMessage(), e);
        model.addAttribute("error", e.getMessage());
        return "500";
    }

}
